package org.copper.utils
{
	import flash.geom.Point;

	public final class MathUtil
	{
		public static function createParabolicWave(lenght:uint, maxVal:Number):Array
		{
			const ans:Array = [];
			ans.length = lenght;
			const xStep:Number = (1/lenght) * 2;
			const border:uint = lenght - 1;
			var x:Number;
			var i:uint = 0;
			for (x = -1; x <= 1; x += xStep)
			{
				if (i < border)
				{
					ans[i] = (x * x) * maxVal;
				}
				else if (i == border)
				{
					ans[i] = maxVal;
				}
				i++;
			}
			return ans;
		}
		
		
		public static function createArc(center_x:Number, center_y:Number, radius:Number, angle_from:Number, angle_to:Number, precision:Number):Array
		{
			const angle_diff :Number = angle_to - angle_from;
			const steps      :uint = Math.round(angle_diff*precision);
			const sAng       :Number = angle_from * DEG_TO_RAD;
			const ans        :Array = [];
			ans.length       = steps;
			
			
			ans[0] = new Point(center_x+radius*Math.cos(sAng), center_y+radius*Math.sin(sAng));
			
			for (var i:int=1; i<=steps; i++) 
			{
				const angle:Number = (angle_from+angle_diff/steps*i) * DEG_TO_RAD;
				ans[i] = new Point(center_x + (radius * Math.cos(angle)), center_y + (radius * Math.sin(angle)));
			}
			
			return ans;
		}
		
		private static const DEG_TO_RAD :Number = Math.PI/180;
	}
}